package cn.cmkj.auction.data.http;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by cunguoyao on 2018/1/29.
 */

public class ShuhuaProps implements Serializable {

    public String name;
    public String value;

    public ShuhuaProps(String name, String value) {
        this.name = name;
        this.value = value;
    }

    public static ShuhuaProps parseFromJson(JSONObject json) {
        if(json != null) {
            ShuhuaProps prop = new ShuhuaProps(json.optString("name", ""), json.optString("value", ""));
            return prop;
        }
        return null;
    }

    public static List<ShuhuaProps> parseJsonArray(JSONArray array) {
        List<ShuhuaProps> list = new ArrayList<>();
        if(array != null && array.length() > 0){
            for(int i=0;i<array.length();i++){
                list.add(parseFromJson(array.optJSONObject(i)));
            }
        }
        return list;
    }
}
